package top.anydata.lifeofcode.lifesystem.dao.sys.user;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import top.anydata.lifeofcode.lifesystem.entity.sys.user.SysAuthPermissionEntity;
import top.anydata.lifeofcode.lifesystem.entity.sys.user.SysAuthRoleEntity;

import java.util.Set;

/**
 * 功能描述:
 *
 * @author <a href="mailto:caingao@anydata.top">CainGao</a>
 * @version V_1.0
 * @date 2024/1/29 4:54 PM
 */
@Repository
public interface ISysAuthRoleRepository extends JpaRepository<SysAuthRoleEntity,Integer> {

    @Query(value = "SELECT r.permissions FROM SysAuthRoleEntity r WHERE r.id = :roleId")
    Set<SysAuthPermissionEntity> findPermissionsByRoleId(@Param("roleId") Integer roleId);


    @Override
    @Modifying
    @Query(value = "update SysAuthRoleEntity s set s.isDeleted = 1 where s.id = ?1")
    void deleteById(Integer integer);
}
